//
//  ShoppingCarListVC.m
//  NormalFramework
//
//  Created by beisheng03 on 2018/3/12.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "ShoppingCarListVC.h"
#import "ShoppingCarCell.h"
#import "ShopCarBottomView.h"
@interface ShoppingCarListVC ()
@property (nonatomic, weak) ShopCarBottomView *bottomView;
@end

@implementation ShoppingCarListVC


- (ShopCarBottomView *)bottomView{
    
    if (!_bottomView) {
        
        ShopCarBottomView *temp = (ShopCarBottomView *)[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([ShopCarBottomView class]) owner:nil options:nil].firstObject;
        
        CGFloat bottomViewH = IPhoneX ? 83 : 49;
        
        if (self.isPush) {
            
            temp.frame = CGRectMake(0, KScreenH - bottomViewH, KScreenW, bottomViewH);

        } else {
            
            temp.frame = CGRectMake(0, KScreenH - bottomViewH - 49, KScreenW, 49);

        }
        
        
        _bottomView = temp;
        
        [self.view addSubview:temp];
        
    }
    
    return _bottomView;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    [self.plainTableView registerNib:[UINib nibWithNibName:NSStringFromClass([ShoppingCarCell class]) bundle:nil] forCellReuseIdentifier:[ShoppingCarCell identifierStr]];
    
    self.plainTableView.estimatedSectionHeaderHeight = 0;
    self.plainTableView.estimatedSectionFooterHeight = 0;
    self.plainTableView.rowHeight = 90;
    
    self.plainTableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenW, 49)];
    
    self.bottomView.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"编辑" style:UIBarButtonItemStylePlain target:self action:@selector(editBtnDidClick)];
    
}

- (void)editBtnDidClick{
    
    if ( [self.navigationItem.rightBarButtonItem.title isEqualToString:@"编辑"]) {
        self.navigationItem.rightBarButtonItem.title = @"完成";
    } else {
        
        self.navigationItem.rightBarButtonItem.title = @"编辑";

    }
    
   
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ShoppingCarCell *cell = [tableView dequeueReusableCellWithIdentifier:[ShoppingCarCell identifierStr]];
    
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
